@layout("home.main")

@section("content")
<div class="main-wrap">
    <div class="main">
        <div class="main-content">
            <div class="title">
                <a href="/">Turui</a> &raquo; 设置
            </div>
            <div class="main-box">
                <p class="red"></p>
                {{ Form::open() }}
                {{ Form::token() }}
                <table cellpadding="5" cellspacing="8" border="0" width="100%" class="fs12">
                        <tr>
                            <td width="120" align="right">用户名</td>
                            <td width="auto" align="left">{{ Auth::user()->uname }}</td>
                        </tr>
                        <tr>
                            <td width="120" align="right">电子邮件</td>
                            <td width="auto" align="left">{{ Form::text("email",Auth::user()->email,array("class"=>"sl w200")) }} 不公开，仅供取回密码，务必正确填写且记住。</td>
                        </tr>
                        <tr>
                            <td width="120" align="right">个人网站</td>
                            <td width="auto" align="left">{{ Form::text("url",Auth::user()->userinfo->url,array("class"=>"sl")) }} http://...</td>
                        </tr>
                        <tr>
                            <td width="120" align="right">个人简介</td>
                            <td width="auto" align="left">{{ Form::textarea("about",Auth::user()->userinfo->about,array("class"=>"ml")) }}</textarea></td>
                        </tr>
                        <tr>
                            <td width="120" align="right"></td>
                            <td width="auto" align="left">{{ Form::submit("保存设置",array("class"=>"textbtn","name"=>"submit")) }}</td>
                        </tr>
                    </table>
                {{ Form::close() }}
            </div>
            <div class="title">设置头像</div>
            <div class="main-box">
                <p class="red"></p>
                    <table cellpadding="5" cellspacing="8" border="0" width="100%" class="fs12">
                        <tr>
                            <td width="120" align="right">当前头像</td>
                            <td width="auto" align="left">
                            <img src="{{ Auth::user()->userinfo->avatar }}" class="avatar" border="0" align="default" auto="">
                            </td>
                        </tr>
                        <tr>
                            <td width="120" align="right">选择头像图片</td>
                            <td width="auto" align="left">
                            {{ Form::button("上传",array("class"=>"button","id"=>"buttonUpload","onclick"=>"return ajaxFileUpload();")) }}
                            {{ Form::file("imgfile",array("id"=>"imgfile","size"=>45,"class"=>"input")) }} (最大300K)
                            </td>
                        </tr>
                    </table>
            </div>
        </div>
        <!-- main-content end -->
        <div class="main-sider">
            @include("home.slidebar")
        </div>
        <!-- main-sider end -->
    </div>
<!-- main end -->
</div>
<script type="text/javascript" src="http://bbs.shaogood.com/static/js/ajaxfileupload.js"></script>
<script type="text/javascript">
function ajaxFileUpload(){
    $.ajaxFileUpload ({
        url:'{{ URL::base()."/upload" }}',
        secureuri:false,
        fileElementId:'imgfile',
        dataType: 'json',
        success: function (data)
        {
            if(typeof(data.error) != 'undefined')
            {
                if(data.error == 'fails')
                {
                    alert(data.msg);
                }else
                {
                    $(".avatar").attr("src",data.msg);
                }
            }
        },
        error: function (data, status, e)
        {
            alert(e);
        }
    });
}
</script>

@endsection